function Query( vArg ) {
  this.arr = [ ];

  switch( typeof vArg ){
  	case "string":
  	  switch( vArg.charAt( 0 ) ){

 		    case "#":
 		      var obj = document.getElementById( vArg.substring( 1 ) );
 		      this.arr.push( obj );
 		    break;

        case ".":
          var c = getByClassName( vArg.substring( 1 ) );
          for( var i = 0; i < c.length; i ++ ){
            this.arr.push( c[i] );
          }
        break;

        default:
          var a = document.getElementsByTagName( vArg );
          for( var j = 0; j < a.length; j ++ ){
            this.arr.push( a[j] );
          }
        break;

  	  }
  	break;

    case 'object':
      return vArg;
    break;

    case 'function':
      window.addEventListener( 'load', vArg, false );
    break;
  }

  return this.arr;

}


//基础 函数
function  getByClassName( c ) {
  var a = [ ];
  var e = document.getElementsByTagName( '*' );
  for( var i=0; i<e.length; i++ ){
    var aClass = e[i].className;
    var aC = aClass.split(' ');
    for( var j=0; j<aC.length; j++ ){
      if( aC[j] == c ){
        a.push( e[i] );
        break;
      }
    }
  }
  return a;
}

function ajax() {
  this.aj = new XMLHttpRequest( ) || new ActiveXObject( "Microsoft.XMLHTTP" );
}

ajax.prototype.get = function( url, fn ) {
  this.aj.open( "GET",url, true );
  this.aj.send( );
  var _this = this;
  this.aj.onreadystatechange = function( ){
    if( _this.aj.readyState == 4 && _this.aj.status == 200 ){
      fn( _this.aj.responseText );
    }
  }
}

function Ajax( ){
  return new ajax( );
}

//返回 query 对象
function selector( vArg ) {
  return new Query( vArg );
}
